package constants

type WSCode int

const (
	WS_OK 					WSCode = 200

	WS_NO_COINPAIR			WSCode = 4100
	WS_PARAMETER			WSCode = 4101
	WS_ERROR_REQUEST 		WSCode = 4102
)

var wsMessage = map[int]string{

	200:  		"success",

	// 交易对不存在
	4100: 		"trade does not exist",

	// 参数错误
	4101: 		"parameter error",

	// 错误请求，多次请求同一交易对时
	4102: 		"error request",
}

// 消息编号
func (code WSCode) GetCode() int {
	return int(code)
}

// 消息内容
func (code WSCode) GetMessage() string {
	if v, ok := wsMessage[int(code)]; ok {
		return v
	}
	return ""
}

// 消息号
type MsgId int

const (
	// 客户端Ping消息
	MSGID_PING_REQUEST 			MsgId = 10000

	// 响应Ping消息
	MSGID_PONG_RESPONSE 		MsgId = 10001

	// 访问交易对数据
	MSGID_JOIN_REQUEST 			MsgId = 10002
	MSGID_JOIN_RESPONSE 		MsgId = 10003

	// 订单
	MSGID_ORDER_RESPONSE  		MsgId = 10005
	// 委托单
	MSGID_TRUST_RESPONSE 		MsgId = 10007

	MSGID_ERROR_RESPONSE 		MsgId = 99999
)

func (c MsgId) Enum() int {
	return int(c)
}